// of liability and disclaimer of warranty provisions.

#ifndef ADDRSPACE_H
#define ADDRSPACE_H

#include "copyright.h"
#include "filesys.h"
#include "syscall.h"

#define UserStackSize        1024     // increase this as necessary!

class AddrSpace {
  public:
    AddrSpace(OpenFile *executable);    // Create an address space,
                    // initializing it with the program
                    // stored in the file "executable"
    ~AddrSpace();            // De-allocate an address space
    unsigned int TestBitMap(unsigned int pages); //used to check is section is clear for new process
    bool TestBitMapPages(unsigned int pages, int offset);// used to check if all pages are clear of entire process
    void InitRegisters();        // Initialize user-level CPU registers,
                    // before jumping to user code


    //  used to get the space id from the thread
    //  currently the SpaceID will start at 0 and increment
    //  for each new thread.
    //typedef int GetSpaceID(); // return the value of the spaceid

    void SaveState();            // Save/restore address space-specific
    void RestoreState();        // info on a context switch 


    void incrementSpaceId();
    SpaceId GetSpaceId();
    void initSpaceId();
    void DeAlloc();

  private:
    TranslationEntry *pageTable;    // Assume linear page table translation
                    // for now!
    unsigned int numPages;        // Number of pages in the virtual 
                    // address space

    SpaceId LocalSpaceId;  


};

#endif // ADDRSPACE_H

